<%@ page pageEncoding="UTF-8"%>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<%
    //JSP将请求默认是使用ISO-8859-1，而大多数浏览器都是以UTF-8编码发送请求数据.所以，如果不设置编码，那么就会导致乱码。
    request.setCharacterEncoding("UTF-8");

    String name = request.getParameter("name");

    //由于jsp中cookie无法保存中文，故URLEncoder编码，读取时再URLEncoder解码
    name = java.net.URLEncoder.encode(name, "UTF-8");
    Cookie cookie = new Cookie ("name",name);
    response.addCookie(cookie);
    cookie.setMaxAge(50 * 50); //Time is in Minutes
%>
<body>
<a href="cookie3.jsp">Continue</a>
</body>
</html>